<!DOCTYPE>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="__PUBLIC__/Home/css/user_center.css">
    <script type="text/javascript" src="__PUBLIC__/Admin/js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Common/Layer/layer.js"></script>
    <title>修改密码</title>

    <script>
    /*
        function check_from(a){
           var sms_code = $('#sms_code').val();
           var hidden = $('#hidden').val();
           var password = $('#password').val();
           var repwd = $('#repwd').val();
           if(sms_code == ''){
              layer.tips('验证码必填','#sms_code');
              return false;
           }
           if(password == ''){
              layer.tips('密码必填','#password');
              return false;
           }
           if(repwd == ''){
              layer.tips('确认密码必填','#repwd');
              return false;
           }
           if(password != repwd){
              layer.tips('2次输入的密码不同','#repwd');
              return false;
           }
           if(hidden != sms_code){
              layer.tips('验证码错误','#sms_code');
              return false;
           }

           $.ajax({
              type: "POST",
              url: "{:U('User/update_pwd')}",
              data: "mobile="+a+"&password="+password,
              success: function(msg){
                if(msg==1){
                    parent.layer.msg('操作成功', { icon: 1, time: 1000 },function(){
                    window.location.href="__SELF__";
                });
             }else{
                    parent.layer.msg('操作失败', {icon: 2, time: 2000 }); 
             }
            }

           });
        }
*/
    </script>
</head>

<body>
<!-- 栏目 -->
<include file="Public:header_center" />

<!-- 内容 -->
<style>
    .col_detail{
        width: 250px;
        height:260px;
        border: 1px solid #CCCCCC;
        margin: 10px 5px;
        float: left;
    }

    .col_detail ul {
        width: 240px;
        margin: 5px auto;
    }
</style>
<div style="background-color:#f5f5f5;">
    <div class="content" style="width:1200px;">
        <include file="Public:left_center" />
        <div class="center-right right">
            <h3 class="title">修改密码</h3>
            <div class="Options" style=" width:1050px; background-color:#FFF; padding:20px;">
                <div id="content"  style="overflow: hidden;zoom: 1">
                <form action="{:U('User/update_pwd')}" method="post" onsubmit="return check();">
                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="pwd_table">
                  <tr>
                    <td width="35%" height="34"><div align="right">已验证的手机号：</div></td>
                    <td width="65%"><label for="textfield"></label>
                    <input type="text" name="mobile" id="mobile" value="{$_SESSION['mobile']}"></td>
                  </tr>
                  <tr>
                    <td height="36"><div align="right">请填写手机校验码：</div></td>
                    <td><input type="text" name="sms_code" id="sms_code" style="border:1px solid #CCC; width:60px; height:26px; ">
                    	<input type="button" style=" width:120px; height:26px;color:#FFF; background:#555; border-radius:3px;" id="btn" value="免费获取验证码" onclick="sendCode(this);" />
                    </td>
                    <input type="text" id="hidden" value="" />
                  </tr>
                  <tr>
                    <td height="37"><div align="right">新密码：</div></td>
                    <td><input type="password" name="password" id="password" style="border:1px solid #CCC; height:26px;"></td>
                  </tr>
                  <tr>
                    <td height="36"><div align="right">重复新密码：</div></td>
                    <td><input type="password" name="repassword" id="repassword" style="border:1px solid #CCC; height:26px;"></td>
                  </tr>
                  <tr>
                    <td height="53">&nbsp;</td>
                    <td><input type="submit" name="submit" value="提交" style=" padding:5px 60px; border-radius:3px; background:#4ecf5b; color:#FFF;"></td>
                  </tr>
                  <tr>
                    <td height="64" colspan="2"><div align="center"></div></td>
                  </tr>
                </table>
				</form>
              </div>

                </div>
            </div>
        </div>
    </div>
    <input type="hidden" id="hidden_sms">

    <!-- 底部 -->
    <include file="Public:footer_center" />


<script>
//发送短信
var clock = '';
var nums = 45; //有效时间(秒)
var btn;
function sendCode(thisBtn){ 
  var mobile = $('#mobile').val();
  if(!checkMobile(mobile)){
    alert('请输入正确的手机号');
    return false;
  }else{
    btn = thisBtn;
    btn.disabled = true; //将按钮置为不可点击
    btn.value = nums+' 秒后重试';
    clock = setInterval(doLoop, 1000); //一秒执行一次
    //提交短信
    $.get("{:U('User/ajax_get_mobile')}", { mobile:mobile },function(data){
      $('#hidden_sms').val(data);
    });
  }
}
//倒计时
function doLoop(){
  nums--;
  if(nums > 0){
    btn.value = nums+' 秒后重试';
  }else{
    clearInterval(clock); //清除js定时器
    btn.disabled = false;
    btn.value = '重新获取';
    nums = 45; //重置时间
  }
}
//检查手机号合法
function checkMobile(str) {
    var re = /^1\d{10}$/
    if (re.test(str)) {
        return true;
    } else {
        return false;
    }
}
</script>
<script>
function check(){
  var mobile = $('#mobile').val();
  if(mobile == ''){
    alert('手机号不能为空');
    return false;
  }
  var sms_code = $('#sms_code').val();
  if(sms_code == ''){
    alert('验证码不正确');
    return false;
  }
  var password = $('#password').val();
  if(password == ''){
    alert('密码不能为空');
    return false;
  }
  var repassword = $('#repassword').val();
  if(password != repassword){
    alert('重复密码不正确');
    return false;
  }
  return true;
}
</script>


</body>
</html>
